<?php
// +----------------------------------------------------------------------
// | NotFound [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 Tangchao All rights reserved.
// +----------------------------------------------------------------------
// | Author: Tangchao <admin@ytecn.com>
// +----------------------------------------------------------------------
namespace plugins\post_photos;
use cmf\lib\Plugin;
use app\portal\model\PortalPostModel;
use think\facade\Request;
class PostPhotosPlugin extends Plugin
{

    public $info = [
        'name'        => 'PostPhotos',
        'title'       => '文章相册',
        'description' => '文章相册',
        'status'      => 1,
        'author'      => 'Tangchao',
        'version'     => '1.1',
        'demo_url'    => 'https://qq.ytecn.com',
        'author_url'  => 'https://qq.ytecn.com'
    ];

    public $hasAdmin = 0;

    public function install()
    {
        return true;
    }

    public function uninstall()
    {
        return true;
    }

    public function afterContent($param)
    {
        $config = $this->getConfig();
        $this->assign($config);
        $param = Request::instance()->param();
        $PostObj = PortalPostModel::get($param['id']);
        if (isset($PostObj['more']['photos'])) {
            $this->assign('photos', $PostObj['more']['photos']);
        } else {
            $this->assign('photos', "");
        }
        if (isset($PostObj['more']['files'])) {
            $this->assign('files', $PostObj['more']['files']);
        } else {
            $this->assign('files', "");
        }
        echo $this->fetch('photos');
    }
}